<?php
/**
 * 快速排序
 * @return mixed
 */
public function quickSort($array)
{
//        $array = [1, 2, 3, 4, 5, 6, 7, 8, 9];
    $count = count($array);
    if ($count < 2) {
        return $array;
    }
    $left = [];
    $right = [];
    $i = 1;

    for ($i; $i < $count; $i++) {
        if ($array[$i] <= $array[0]) {
            $left[] = $array[$i];
        } elseif ($array[$i] > $array[0]) {
            $right[] = $array[$i];
        }
    }
    return array_merge($this->quickSort($left), [0 => $array[0]], $this->quickSort($right));

}

$arrayy = [9, 8, 7, 6, 5, 4, 3, 2, 1];
$array = $this->quickSort($arrayy);
var_dump($array);